package com.easy.controller;

import com.easy.bean.Orderdetails;
import com.easy.bean.Product;
import com.easy.dao.ProductDao;
import com.easy.service.IOrderdetailsService;
import com.easy.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("page")
public class PageController {

//    @RequestMapping("upload")
//    public String upload(){
//        return "upload.html";
//    }

    @Autowired
    IProductService productService;

    @RequestMapping("index")
    public String index(){
        return "front/index.html";
    }

    @RequestMapping("login")
    public String login(){
        return "front/login.html";
    }

    @RequestMapping("cart")
    public String cart(){
        return "front/cart.html";
    }

    @RequestMapping("about")
    public String about(){
        return "front/about.html";
    }

    @RequestMapping("blog")
    public String blog(){
        return "front/blog.html";
    }

    @RequestMapping("blogde")
    public String blogde(){
        return "front/blog-details.html";
    }

    @RequestMapping("checkout")
    public String checkout(){
        return "front/checkout.html";
    }
    @Autowired
    IOrderdetailsService orderdetailsService;
    @GetMapping("checkoutData")
    @ResponseBody
    public List<Orderdetails> ordepage(int orderid){
        return orderdetailsService.getOrderdetailsById(orderid);
    }

    @RequestMapping("compare")
    public String compare(){
        return "front/compare.html";
    }

    @RequestMapping("contact")
    public String contact(){
        return "front/contact.html";
    }

    @RequestMapping("error")
    public String error(){
        return "front/error-404.html";
    }

    @RequestMapping("faq")
    public String faq(){
        return "front/faq.html";
    }

    @RequestMapping("account")
    public String account(){
        return "front/my-account.html";
    }

    @RequestMapping("register")
    public String register(){
        return "front/register.html";
    }

    @RequestMapping("shoppage")
    public String shop(){
        return "front/shop.html";
    }




    @RequestMapping("shopleft")
    public String shopleft(){
        return "front/shop-left-sidebar.html";
    }

    @GetMapping("propage")
    public String propagePage() {
        return "front/single-product.html"; // 返回静态页面
    }

    @GetMapping("productData")
    @ResponseBody
    public Product propage(int proid){
        return productService.getProductById(proid);
    }

    @RequestMapping("wishlist")
    public String wishlist(){
        return "front/wishlist.html";
    }

    @RequestMapping("payment")
    public String payment(){
        return "front/payment.html";
    }

    @RequestMapping("order")
    public String order(){
        return "front/order.html";
    }



}
